import React, { memo } from 'react'

import { Button, Card, FloatButton } from 'antd';
import MList from './list/list';
import './css/article.css'
import { useNavigate } from 'react-router-dom';
import { useSelector } from 'react-redux';

export default memo(() => {
  const navigate = useNavigate()
  const onMarkown = () => {
    navigate('/home/article/markown',
      {
        state: {
          isedit: 0
        }
      })
  }
  const goAdmin = (val) => {
    if (val == 1) {
      navigate('/home/homes/check',
        {
          state: { state: val }
        })
    }else if(val == 2){
      navigate('/home/homes/overcheck',
        {
          state: { state: val }
        })
    }else {
      navigate('/home/homes/dustbin',
        {
          state: { state: val }
        })
    }

  }
  const profile = useSelector(state => state.profile.profile)
  return (
    <div className='article'>
      <MList />
      <div className='userInfo'>
        <Card
          style={{
            width: 300,
            marginBottom: '10px'
          }}
        >
          <div>
            <div className='userInfo-article'>
              <div className='avatar'>
                <img width={80} height={80} src={profile.result?.avatar} />
              </div>
              <div className='article-number'>
                <div onClick={() => goAdmin(1)}>草稿箱{1}</div>
                <div onClick={() => goAdmin(2)}>已发表{2}</div>
                <div onClick={() => goAdmin(3)}>垃圾箱{3}</div>
              </div>
            </div>
            <Button onClick={() => onMarkown()} type="primary" block>+开始创作</Button>
          </div>
        </Card>
        <Card
          style={{
            width: 300,
          }}

        >
          <div style={{ textAlign: 'center' }}>
            粤ICP备2022070653号-1 <br />
            粤公网安备 44070502000613号
          </div>
        </Card>
      </div>
      <FloatButton.BackTop />
    </div>
  )
})
